package com.hksj.Intelligentmanagement.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.hksj.Intelligentmanagement.common.Result;
import com.hksj.Intelligentmanagement.dto.SchedulingDTO;
import com.hksj.Intelligentmanagement.service.SchedulingService;
import com.hksj.Intelligentmanagement.vo.SchedulingVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName SchedulingController
 * @Description TODO
 * @Author @陈章
 * @Date 2023/3/30 15:45
 * @Version 1.0
 */
@Api(tags = "护士班次")
@RestController
@RequestMapping("/api/scheduling")
public class SchedulingController {
    @Autowired
    private SchedulingService service;

    @ApiOperation(value = "班次新增")
    @PostMapping("/addScheduling")
    public Result addScheduling(@RequestBody @Validated(SchedulingDTO.Save.class) SchedulingDTO schedulingDTO) {
        service.addScheduling(schedulingDTO);
        return Result.ok();
    }


    @ApiOperation(value = "班次删除")
    @PostMapping("/delScheduling")
    public Result delScheduling(String id) {
        service.delScheduling(id);
        return Result.ok();
    }

    @ApiOperation(value = "查询所有班次")
    @PostMapping("/findAllScheduling")
    public Result findAllScheduling(@RequestBody SchedulingDTO schedulingDTO) {
        IPage<SchedulingVo> iPage = service.findAllScheduling(schedulingDTO);
        return Result.ok(iPage);
    }

    @ApiOperation(value = "根据id修改班次")
    @PostMapping("/updateSchedulingById")
    public Result updateSchedulingById(@RequestBody SchedulingDTO schedulingDTO) {
        service.updateSchedulingById(schedulingDTO);
        return Result.ok();
    }



}
